package com.sun.lib.base.basemvp;
/*
 *
 * #                                                   #
 * #                       _oo0oo_                     #
 * #                      o8888888o                    #
 * #                      88" . "88                    #
 * #                      (| -_- |)                    #
 * #                      0\  =  /0                    #
 * #                    ___/`---'\___                  #
 * #                  .' \\|     |# '.                 #
 * #                 / \\|||  :  |||# \                #
 * #                / _||||| -:- |||||- \              #
 * #               |   | \\\  -  #/ |   |              #
 * #               | \_|  ''\---/''  |_/ |             #
 * #               \  .-\__  '-'  ___/-. /             #
 * #             ___'. .'  /--.--\  `. .'___           #
 * #          ."" '<  `.___\_<|>_/___.' >' "".         #
 * #         | | :  `- \`.;`\ _ /`;.`/ - ` : | |       #
 * #         \  \ `_.   \_ __\ /__ _/   .-` /  /       #
 * #     =====`-.____`.___ \_____/___.-`___.-'=====    #
 * #                       `=---='                     #
 * #     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   #
 * #                                                   #
 * #               佛祖保佑         永无BUG              #
 * #                                                   #
 */

import android.util.Log;

import com.sun.lib.net.DataManager;
import com.sun.lib.rx.Disposables;

import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;

/**
 * Created by ESSC07 on 2020/11/19.
 */
public class BaseModel implements IModel {
    protected DataManager dataManager;
    protected CompositeDisposable compositeDisposable;


    public BaseModel() {
        this.dataManager = DataManager.getInstance();
    }

    @Override
    public void addDisable(Disposable disposable) {
        getDisposable().add(disposable);
    }

    protected CompositeDisposable getDisposable() {
        if (compositeDisposable == null)
            compositeDisposable = new CompositeDisposable();
        return compositeDisposable;
    }

    @Override
    public void dispose() {
        if (compositeDisposable != null && !compositeDisposable.isDisposed()) {
            Log.d("TAG", "清空所有disposable:" + compositeDisposable.size());
            compositeDisposable.clear();
        }
    }
}
